package shuishijie.suishijie.model;

import android.text.TextUtils;



/**
 * Created by mindx on 2017/8/29.
 */

public class ShopInfo {
    private static final String DEFAULT_BG = "http://fcp.oss-cn-beijing.aliyuncs.com/shop/background/8558.jpg";
    private static final String DEFAULT_HEAD = "http://fcp.oss-cn-beijing.aliyuncs.com/user/headPortrait/defaultHead.png";
    /**
     * 精选商品品牌id
     */
    public int shopgoods_id;

    /**
     * background_acc_id : http://fcp.oss-cn-beijing.aliyuncs.com/shop/background/8558.jpg
     * shareURL : http://mall.duomaide.com/dist/index.html#/main/store?shop_id=5
     * shopName : 18698627604
     * shopPath : http://fcp.oss-cn-beijing.aliyuncs.com/user/headPortrait/defaultHead.png
     * shop_id : 5
     */

    private String background_acc_id;
    public String shareURL;

    private String shopDescription;
    private static final String DESCRIPTION = "精选每一件商品，带给你好的购物体验";
    private String shopInfo;

    public String shopName;
    private String shopPath;
    private String headPath;
    public int shop_id;


    /**
     * /user/myinit.json
     * availableMoney : 0
     * backgroundPath : http://fcp.oss-cn-beijing.aliyuncs.com/shop/background/8558.jpg
     * cartNumber : 6
     * coinNumber : 0
     * couponNumber : 0
     * imgPath : http://fcp.oss-cn-beijing.aliyuncs.com/user/headPortrait/defaultHead.png
     */

    public double availableMoney;
    private String backgroundPath;
    public int cartNumber;
    public int coinNumber;
    public String customService_id;
    public int integral;
    public int couponNumber;
    private String imgPath;
    public String mobile;


    public String getBackgroundPath() {
        return !TextUtils.isEmpty(backgroundPath) ? backgroundPath : !TextUtils.isEmpty(background_acc_id) ? background_acc_id : DEFAULT_BG;
    }

    public void setBackgroundPath(String backgroundPath) {
        this.backgroundPath = backgroundPath;
    }

    public String getShopPath() {
        return !TextUtils.isEmpty(shopPath) ? shopPath : !TextUtils.isEmpty(imgPath) ? imgPath : !TextUtils.isEmpty(headPath) ? headPath : DEFAULT_HEAD;
    }

    public void setShopPath(String shopPath) {
        this.shopPath = shopPath;
    }

    public void setImgPath(String imgPath) {
        this.imgPath = imgPath;
    }

    public String getShopDescription() {
        return !TextUtils.isEmpty(shopDescription) ? shopDescription : (!TextUtils.isEmpty(shopInfo) ? shopInfo : DESCRIPTION);
    }

    public void setShopDescription(String shopDescription) {
        this.shopDescription = shopDescription;
        this.shopInfo = shopInfo;
    }

    public String getShopInfo() {
        return shopInfo;
    }

    public void merge(ShopInfo info) {
        if (info == null) {
            return;
        }
        if (!TextUtils.isEmpty(info.getBackgroundPath())) {
            setBackgroundPath(info.getBackgroundPath());
        }
        if (!TextUtils.isEmpty(info.mobile)) {
            mobile = info.mobile;
        }
        if (shopgoods_id > 0) {
            shopgoods_id = info.shopgoods_id;
        }
        if (!TextUtils.isEmpty(info.shopName)) {
            shopName = info.shopName;
        }
        if (!TextUtils.isEmpty(info.headPath)) {
            headPath = info.headPath;
        }
        if (!TextUtils.isEmpty(info.shopPath)) {
            shopPath = info.shopPath;
        }
        if (info.shop_id > 0) {
            shop_id = info.shop_id;
        }
        if (info.couponNumber > 0) {
            couponNumber = info.couponNumber;
        }
        if (info.coinNumber > 0) {
            coinNumber = info.coinNumber;
        }
        if (!TextUtils.isEmpty(info.shareURL)) {
            shareURL = info.shareURL;
        }
        if (!TextUtils.isEmpty(info.shopPath)) {
            shopPath = info.shopPath;
        }
        if (!TextUtils.isEmpty(info.customService_id)) {
            customService_id = info.customService_id;
        }
        if (!TextUtils.isEmpty(info.getShopDescription())) {
            setShopDescription(info.getShopDescription());
        }
        if (!TextUtils.isEmpty(info.getShopPath())) {
            setShopPath(info.getShopPath());
        }
//        AppDBHelper.getInstance().setConfigValue("SHOP_INFO", JsonUtil.toString(this));
    }
}
